#!/bin/bash -e

# TODO: 99% sure there is a better way to do this
GCC_VERSION_MAJOR=$(c++ --version | grep -Po '\d\.\d\.\d' | grep -Po '^\d+' | head -1)

ls -l $1/../coveralls-repo-token
COVERALLS_REPO_TOKEN=$(cat $1/../coveralls-repo-token)
TRAVIS=true
CI=true

coveralls                                                       \
    --repo-token="${COVERALLS_REPO_TOKEN}"                      \
    --build-root $1                                             \
    --exclude-pattern '_test\.cpp$'                             \
    --exclude-pattern bits                                      \
    --gcov-options '\-lp' --gcov "gcov-${GCC_VERSION_MAJOR}"
